package com.liveneo.adapter.mobile.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.liveneo.adapter.base.entity.PrpmDictDetail;
import com.liveneo.adapter.base.entity.PrpmDictType;
import com.liveneo.adapter.base.mapper.PrpmDictDetailMapper;
import com.liveneo.adapter.base.mapper.PrpmDictTypeMapper;
import com.liveneo.adapter.mobile.model.dto.ConstantDto;
import com.liveneo.adapter.mobile.service.DictDetailService;

@Service
public class DictDetailServiceImpl implements DictDetailService{
    @Autowired
    private PrpmDictDetailMapper  prpmDictMapper;
    @Autowired
    private PrpmDictTypeMapper prpmDictTypeMapper;

    public List<PrpmDictDetail> queryDictsByDtUuid(String dtCode) {
        return prpmDictMapper.queryDictsByDtUuid(dtCode);
    }

    public List<ConstantDto> selectDictInfo(String uuid, boolean isChild) {
        List<ConstantDto> pList = prpmDictMapper.selectDictInfo(uuid);
        for (ConstantDto constantDto : pList) {
            if (isChild) {
                List<ConstantDto> cList = prpmDictMapper.selectDictChild(constantDto);
                constantDto.setChilds(cList);
            }
        }
        return pList;
    }

    public List<PrpmDictType> selectDictType() {
        return prpmDictTypeMapper.selectDictType();
    }
}
